//
//  JYTAboutJYTViewController.m
//  JYT_IOS
//
//  Created by nxa-tankeke on 17/1/17.
//  Copyright © 2017年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTAboutJYTViewController.h"

@interface JYTAboutJYTViewController ()<UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>
@property (nonatomic, strong)UIImageView *imageView;
@property (nonatomic, strong)UILabel *carManLabel;
@property (nonatomic, strong)UILabel *nameLabel;
@property (nonatomic, strong)UILabel *versionLabel;
@property (nonatomic, strong)UILabel *timeLabel;
@property (nonatomic, strong)UIView *header;
@property (nonatomic, strong)UITableView *tab;
@property (nonatomic, strong)UIView *footer;
@property (nonatomic, strong)UILabel *tiLabel;

@end

@implementation JYTAboutJYTViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSDictionary *dic = @{@"lftBtnBgImg":@"ic_goback",
                          @"lftBtnTitle":@"no",
                          @"pageTitle":@"关于驾易通",
                          @"rhtBtnBgImg":@"no",
                          @"rhtBtnTitle":@"no"};
    
    [self setNavgationBarWithDic:dic];
    [self addHeader];

    [self addFooter];
    
    [self addTable];
}

- (void)addHeader
{
    UIView *header = [[UIView alloc]init];
    header.frame = CGRectMake(0, 0, CURRENT_SCREEN_WIDTH, 160);
    self.header = header;
   // [self.view addSubview:header];
    
    
    UIImageView *imageView = [[UIImageView alloc]init];
    imageView.image = [UIImage imageNamed:@"驾易通logo"];
    self.imageView = imageView;
    [header addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(header.mas_top).offset(20);
        make.width.equalTo(@(100));
        make.height.equalTo(@(100));
        make.centerX.equalTo(header.mas_centerX);
        
        
    }];
    
    UILabel *versionLabel = [[UILabel alloc] init];
    NSString * key = @"CFBundleShortVersionString";
    NSString * currentVersion = [NSBundle mainBundle].infoDictionary[key];
    versionLabel.text =    [NSString stringWithFormat:@"当前版本 : V%@", currentVersion];;
    versionLabel.textColor = [UIColor colorWithRed:(144 / 255.0) green:(144 / 255.0) blue:(144 / 255.0) alpha:1.0];
    versionLabel.textAlignment = NSTextAlignmentCenter;
    versionLabel.font = [UIFont systemFontOfSize:14];
    self.versionLabel = versionLabel;
    [header addSubview:versionLabel];
    [versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.imageView.mas_bottom).offset(10);
        make.width.equalTo(@(100));
        make.height.equalTo(@(25));
        make.centerX.equalTo(header.mas_centerX);
        
        
    }];
    
    UIView *line = [[UIView alloc]init];
    line.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
    [header addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(header.mas_bottom).offset(0);
        make.right.equalTo(header.mas_right).offset(0);
        make.left.equalTo(header.mas_left).offset(0);
        make.height.equalTo(@(1));
        
    }];
}

-(void)addFooter
{
    UIView *footer = [[UIView alloc]init];
    
    CGFloat H = CURRENT_SCREEN_HEIGHT - 44 *(CURRENT_SCREEN_HEIGHT / 667) * 3 - 64 - 160;
    footer.frame = CGRectMake(0, 0, CURRENT_SCREEN_WIDTH, H);
    self.footer = footer;
   // [self.view addSubview:header];
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.text = @"CopyRight©1989-2016, Nesun.cn";
    timeLabel.textColor = [UIColor colorWithRed:(144 / 255.0) green:(144 / 255.0) blue:(144 / 255.0) alpha:1.0];
    timeLabel.font = [UIFont systemFontOfSize:12];
    self.tiLabel = timeLabel;
    [footer addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(footer.mas_bottom).offset(-10);
        
        make.centerX.equalTo(footer.mas_centerX);
        
    }];
    
    UILabel *companyLabel = [[UILabel alloc] init];
    companyLabel.text = @"深圳市能信安科技股份有限公司";
    companyLabel.textColor = [UIColor colorWithRed:(144 / 255.0) green:(144 / 255.0) blue:(144 / 255.0) alpha:1.0];
    companyLabel.font = [UIFont systemFontOfSize:14];
    [footer addSubview:companyLabel];
    [companyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.tiLabel.mas_top).offset(-5);
        
        make.centerX.equalTo(footer.mas_centerX);
        
        
    }];


}

- (void)addTable
{
    UITableView *tab = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, CURRENT_SCREEN_WIDTH, CURRENT_SCREEN_HEIGHT - 64) style:UITableViewStylePlain];
    tab.delegate = self;
    tab.dataSource = self;
    self.tab = tab;
    [self.tab setTableHeaderView:_header];
    [self.tab setTableFooterView:_footer];
    
    //[self.tab registerNib:[UINib nibWithNibName:NSStringFromClass([JYTFeaturesCell class]) bundle:nil] forCellReuseIdentifier:YGXFeatureCellId];
    [self.view addSubview:tab];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *ID = @"cellabout";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
   
    if (indexPath.row == 0) {
         [cell.textLabel setText:@"功能简介"];
    } else if(indexPath.row == 1){
         [cell.textLabel setText:@"官方网站：http://www.nesun.cn/"];
    } else {
         [cell.textLabel setText:@"微信公众号：nesun"];
    }

    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 44 *(CURRENT_SCREEN_HEIGHT / 667);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
